// 数据格式效验
export const fromDefaultData = (originData, defaultData) => {
	let originType = Object.prototype.toString.call(originData).slice(8,-1)
	let defaultType = Object.prototype.toString.call(defaultData).slice(8,-1)
	switch(defaultType){
		case 'Array':
			return originType === 'Array' 
					? 
						defaultData.length ? originData.map((item,i) => fromDefaultData(item, defaultData[i] || defaultData[0])) : originData
					: 
						(
							console.warn('fromDefaultData function parse data type warn',originData,'from',defaultData)
							,
							[]
						)
		break;
		case 'Object':
			let newJsonData = originType === 'Object' 
								? 
									originData 
								: 
								(
									console.warn('fromDefaultData function parse data type warn',originData,'from',defaultData)
									,
									{}
								)
			for(let key in defaultData){
				newJsonData[key] = fromDefaultData(newJsonData[key], defaultData[key])
			}
			return newJsonData;
		break;
		default:
			return originType === defaultType 
					? 
						originData 
					: 
						(
							console.warn('fromDefaultData function parse warn',originData,'from',defaultData)
							,
							defaultData
						)
		break;
	}
}